//
//  RecruitViewController.m
//  ManageCenter
//
//  Created by macbookpro on 2020/4/17.
//  Copyright © 2020 macbookpro. All rights reserved.
//

#import "RecruitViewController.h"
#import "RecruitTableViewCell.h"
#import "AddRecruitViewController.h"
#import "TaskListViewController.h"

@interface RecruitViewController ()<UITableViewDelegate, UITableViewDataSource>

@end

@implementation RecruitViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithTitle:@"发布" style:UIBarButtonItemStylePlain target:self action:@selector(rightClick)];
    self.navigationItem.rightBarButtonItem = rightItem;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 10;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    RecruitTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell = [[RecruitTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    [cell.taskBtn addTarget:self action:@selector(pushTask:) forControlEvents:UIControlEventTouchUpInside];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 80;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
}

#pragma mark 点击发布按钮
- (void)rightClick {
    NSLog(@"点击了发布按钮");
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main"bundle:nil];//从Storyboard上按照identifier获取指定的界面（VC），identifier必须是唯一的
    AddRecruitViewController *receive = [storyboard instantiateViewControllerWithIdentifier:@"addRecruit"];
    [self.navigationController pushViewController:receive animated:YES];
}

#pragma mark 任务进度
- (void)pushTask:(UIButton *)sender {
    NSLog(@"点击了任务进度按钮");
    TaskListViewController *taskVC = [[TaskListViewController alloc] init];
    [self.navigationController pushViewController:taskVC animated:YES];
}

@end
